<?php
/**
 * @annotate 企业设置类
 * @group   Admin/Company
 * @author   yachtxiao <fuck@fackyou.org>
 */
class CompanyAction extends BaseAction {
	protected $aVerify = array(
   	'index','index_done'
  	);//需要验证的方法
	public function index(){
		$this->assign("Title","公司后台主页");
		$map['cid'] = $_SESSION['company']['cid'];
		$map['is_del'] = 0;
		$com_info = D('company_info')->where($map)->find();
		$this->assign('com_info',$com_info);
		$store = D('store')->where($map)->find();
		$this->assign('store',$store);
		if(!empty($com_info) && !empty($com_info['license']) && !empty($com_info['brand']) && !empty($store)){
			redirect(U('Company/index_done'));
		}
	
		$this->display();
	}
	public function index_done(){
		$this->assign("Title","公司后台主页");
		$map['cid'] = $_SESSION['company']['cid'];
		$map['is_del'] = 0;
		$hid = D('hiring')->where($map)->getField('hiring_id',true);
		$count_check = D('hiring')->where(array('cid' =>$_SESSION['company']['cid']))->getField('check',true);
		$count_check = array_sum($count_check);
		$this->assign('count_check',$count_check);
		$data['hiring_id'] = array('in',$hid);
		$data['is_check'] = 0;
		$data['is_del'] = 0;
		$resume_count = D('send_resume')->where($data)->count();
		$listmes = D('message')->where(array('to'=>$_SESSION['company']['cid'],'is_del'=>0))->select();
		$mess_cou =0;
		foreach($listmes as $k=>$v){
			$listmes[$k]['reply'] = D('message_reply')->where(array('mid'=>$listmes[$k]['mid'],'is_del'=>0))->select();
			if($listmes[$k]['reply'] == ""){
				$mess_cou += 1;
			}
			
		}
		$this->assign('resume_count',$resume_count);
		$this->assign('mess_cou',$mess_cou);
		$list = D('send_resume')->where($data)->order('send_time desc')->limit(3)->select();
		foreach($list as $k=>$v){
			$list[$k]['resume'] =  D('resume')->where(array('resume_id'=>$v['resume_id']))->find();
			$list[$k]['info'] =  D('member_info')->where(array('uid'=>$list[$k]['resume']['uid']))->find();
			$list[$k]['info']['face'] = get_img_url($list[$k]['info']['face']);
			$list[$k]['exper'] =  D('exper')->where(array('uid'=>$list[$k]['resume']['uid'],'is_del'=>0))->select();
			$list[$k]['jobname'] = $job[$list[$k]['hiring_id']];
		}
		$this->assign('list',$list);
		$hiring = D('hiring')->where($map)->order('updateline desc')->limit(8)->select();
		$this->assign('hiring',$hiring);
		$this->display();
	}
}
?>